<template>
	<div>
		<div @click="clickCell" style="text-align: left;color: black;">
			<van-image lazy-load width="100%" height="50vw" :src="goodPic" fit="cover" />
			<div style="text-align: right;">
				<div style="font-size: 0.9rem;">
					{{data.name}}
				</div>
				<div>
					<strong style="color: red;font-size: 1.3rem;">
						￥{{price}}
					</strong>
				</div>
			</div>

		</div>
	</div>
</template>

<script>
	import url from '@/assets/url.json';
	
	export default {
		props: {
			openDetailPage: Function,
			data: Object,
			
		},
		data() {
			return {
				price: '0',
				goodPic: ''
			}
		},
		methods: {
			clickCell() {
				this.openDetailPage(this.data);
			}
		},
		mounted() {
			// 价格加上小数点
			let str = this.data.price;
			let numberPrice=Number.parseInt(str);
			if(numberPrice<10){
				str='00'+str;
			}else{
				if(numberPrice<100){
					str='0'+str;
				}
			}
			
			let arr = str.split('');
			arr.splice(-2,0,'.');
			str = arr.join('');
			this.price=str;
			
			// 处理预览图链接
			let goodPicSrcList=this.data.imgSrc.split(';');
			if(goodPicSrcList.length>=1){
				if(goodPicSrcList[0]!==''){
					this.goodPic=url.ip+'/'+goodPicSrcList[0];
				}
			}
		}
	}
</script>

<style>
</style>